Skip to content

feat(cli): add projects setup command - #4356

Merged
saddlepaddle merged 1 commit into
mainfrom
superset-projects-setup
May 10, 2026
Merged

saddlepaddle merged 1 commit into
mainfrom
superset-projects-setup

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented May 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adopt an existing v2 project on a host without creating a duplicate — the dedup counterpart to projects create. Without this, anyone setting up Superset on a new machine and reaching for the CLI would always create a fresh cloud project, even if their org already has one for the same repo.

superset projects setup <id> (--host <id> | --local) (--parent-dir <path> | --import <path> [--allow-relocate])
  • Positional <id> is the cloud project UUID (find it via superset projects list).
  • --parent-dir <path> triggers clone mode — URL comes from the cloud project, so no --clone <url> needed.
  • --import <path> registers an existing folder.
  • --allow-relocate permits re-importing at a different path when the project is already set up here.

Wraps host-service project.setup, which already handles the no-op-when-already-set-up case and the linkRepoCloneUrl write-back when an imported folder has a remote the cloud project doesn't yet know about.

Pairs with projects create to mirror the desktop's two-button UX (Create vs Import).

Bumps cli 0.2.13 → 0.2.14.

Test plan

  • --help and validation cases (mutex, --allow-relocate requires --import)
  • Live: superset projects setup <id> --local --import <path> against a project already set up returned the existing mainWorkspaceId (idempotent)
  • superset projects setup <id> --local --parent-dir <path> clones a fresh checkout for a project with repoCloneUrl
  • superset projects setup <id> --local --import <path> for a project with no repoCloneUrl writes back via linkRepoCloneUrl if the folder has a remote
  • superset projects setup <id> --host <remote> --parent-dir <path> works against a remote host through the relay

Summary by cubic

Add superset projects setup to attach an existing cloud project to a target host without creating a duplicate. Supports clone or import modes and is idempotent.

  • New Features

    • New command: superset projects setup <id> targeting --host <id> or --local.
    • Modes: clone with --parent-dir <path>, or import with --import <path>; --allow-relocate permits re-import at a new path.
    • Validation: require exactly one of --parent-dir/--import; --allow-relocate only with --import.
    • Uses host-service project.setup; no-op if already set up and writes back missing repo URL when importing.
  • Dependencies

    • Bump @superset/cli from 0.2.13 to 0.2.14.

Written for commit 58f2b93. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Introduced project adoption command with support for clone and import modes, configurable host targets, and relocation options.
  • Chores

    • CLI version updated to 0.2.14.

Review Change Stack

Adopt an existing v2 project on a target host without creating a new
one — the dedup counterpart to `projects create`. Mirrors the desktop's
two-button UX: `create` makes a fresh cloud project, `setup <id>`
attaches an existing one to the host (clone the cloud-stored URL or
register an existing folder).

Bumps cli to 0.2.14.
@coderabbitai

coderabbitai Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d20315ea-7f3c-4e9b-b87f-b504fb042eb3

📥 Commits

Reviewing files that changed from the base of the PR and between ce2679c and 58f2b93.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • packages/cli/cli.config.ts
  • packages/cli/package.json
  • packages/cli/src/commands/projects/setup/command.ts

📝 Walkthrough

Walkthrough

This PR adds a new CLI command for adopting existing projects onto a specified host in either clone or import mode, with validation of mutually exclusive options. Supporting version updates bump the CLI package and config from 0.2.13 to 0.2.14.

Changes

Project Setup Feature

Layer / File(s) Summary
Command Structure and Imports
packages/cli/src/commands/projects/setup/command.ts
Defines the projects setup command with required id positional argument and options for host selection (--host, --local) and adoption mode (--parent-dir, --import, --allow-relocate).
Option Validation
packages/cli/src/commands/projects/setup/command.ts
Enforces mutual exclusivity of --parent-dir and --import, restricts --allow-relocate to import mode, and requires an active organization in context.
Host Resolution
packages/cli/src/commands/projects/setup/command.ts
Resolves the target host from user-provided flags using requireHostTarget and resolveHostTarget with organization ID and bearer token.
Request Mode Construction
packages/cli/src/commands/projects/setup/command.ts
Builds mode payload as either clone (parentDir) or import (repoPath plus allowRelocate) based on validated options.
API Mutation and Response
packages/cli/src/commands/projects/setup/command.ts
Calls project.setup.mutate with project ID and mode, then returns result with host-specific success message.
Version and Release Updates
packages/cli/cli.config.ts, packages/cli/package.json
Bumps CLI version from 0.2.13 to 0.2.14 in both config constant and package manifest.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops with joy so bright,
New projects setup, oh what a sight!
From clone to import, the modes align,
Version bumped to 0.2.14 so fine! 🐰✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch superset-projects-setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@saddlepaddle
saddlepaddle merged commit 08943a5 into main May 10, 2026
15 of 16 checks passed
@github-actions

github-actions Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) ✅ View Branch
Vercel API (Vercel) ✅ Open Preview
Vercel Web (Vercel) ✅ Open Preview
Vercel Marketing (Vercel) ✅ Open Preview
Vercel Admin (Vercel) ✅ Open Preview
Vercel Docs (Vercel) ✅ Open Preview

Preview updates automatically with new commits

@greptile-apps

greptile-apps Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a projects setup CLI subcommand that adopts an existing cloud project on a host — either by cloning its repo into a parent directory or by registering an existing local folder — as the dedup counterpart to projects create. The implementation follows the established patterns from projects create and bumps the CLI version to 0.2.14.

  • setup/command.ts: validates mutual exclusion of --parent-dir / --import and that --allow-relocate only applies to --import mode, then delegates to target.client.project.setup.mutate via the shared resolveHostTarget utility.
  • Version bump (0.2.14) applied consistently across package.json, cli.config.ts, and bun.lock.

Confidence Score: 4/5

Safe to merge; the new command correctly validates its flags, delegates to an existing host-service mutation, and follows established patterns throughout the codebase.

The command logic is straightforward and mirrors projects create. The only notable issue is that the mutual-exclusion guard reuses the same error message whether both flags are present or neither is, which can confuse users who omit both mode flags.

packages/cli/src/commands/projects/setup/command.ts — the mutex error message ambiguity is worth a second look before shipping user-facing docs.

Important Files Changed

Filename Overview
packages/cli/src/commands/projects/setup/command.ts New projects setup command; validation logic is sound but the mutex error message is ambiguous when neither mode flag is provided
packages/cli/cli.config.ts Version bump 0.2.13 → 0.2.14 only
packages/cli/package.json Version bump 0.2.13 → 0.2.14 only

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as superset CLI
    participant HT as resolveHostTarget
    participant HS as Host Service (tRPC)
    participant Cloud as Cloud API

    User->>CLI: "superset projects setup <id> --local --import <path>"
    CLI->>CLI: validate mutex (--parent-dir XOR --import)
    CLI->>CLI: validate --allow-relocate requires --import
    CLI->>HT: "requireHostTarget({local: true})"
    HT-->>CLI: hostId
    CLI->>HT: "resolveHostTarget({hostId, orgId, jwt})"
    HT-->>CLI: "ResolvedHostTarget {client, hostId}"
    CLI->>HS: "project.setup.mutate({projectId, mode: {kind, repoPath, allowRelocate}})"
    HS->>Cloud: "linkRepoCloneUrl (if import & remote found)"
    HS-->>CLI: result
    CLI-->>User: "Set up project <id> on host <hostId>"
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/cli/src/commands/projects/setup/command.ts:29-34
**Mutex error message fires for "neither provided" case too**

`Boolean(undefined) === Boolean(undefined)` is `true`, so a user who omits both flags sees "Specify exactly one of --parent-dir or --import" — a message that reads as if they supplied both rather than neither. The same pattern exists in `create/command.ts`, but here the lack of a `--clone` analogue makes the two-flag surface smaller and the "neither" case more likely to be hit accidentally. A disambiguated check (or a separate `else if` branch) would make the error clearer to users in the omit-both path.

Reviews (1): Last reviewed commit: "feat(cli): add `projects setup` command" | Re-trigger Greptile

Comment on lines +29 to +34
if (Boolean(options.parentDir) === Boolean(options.import)) {
throw new CLIError(
"Specify exactly one of --parent-dir or --import",
"Use --parent-dir <path> to clone, or --import <path> to register an existing folder",
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Mutex error message fires for "neither provided" case too

Boolean(undefined) === Boolean(undefined) is true, so a user who omits both flags sees "Specify exactly one of --parent-dir or --import" — a message that reads as if they supplied both rather than neither. The same pattern exists in create/command.ts, but here the lack of a --clone analogue makes the two-flag surface smaller and the "neither" case more likely to be hit accidentally. A disambiguated check (or a separate else if branch) would make the error clearer to users in the omit-both path.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/commands/projects/setup/command.ts
Line: 29-34

Comment:
**Mutex error message fires for "neither provided" case too**

`Boolean(undefined) === Boolean(undefined)` is `true`, so a user who omits both flags sees "Specify exactly one of --parent-dir or --import" — a message that reads as if they supplied both rather than neither. The same pattern exists in `create/command.ts`, but here the lack of a `--clone` analogue makes the two-flag surface smaller and the "neither" case more likely to be hit accidentally. A disambiguated check (or a separate `else if` branch) would make the error clearer to users in the omit-both path.

How can I resolve this? If you propose a fix, please make it concise.

This branch was previously deployed

1 inactive deployment
preview — 58f2b93f Deployed May 10, 2026 by saddlepaddle via Deploy Web #5161
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant